# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: frank AT apsu DOT be

pkgname=(libmaxminddb mmdblookup)

pkgver=1.8.0
pkgrel=1
pkgdesc="MaxMind GeoIP2 database - split package with library and utilities"
license=('Apache')
arch=('loong64' 'x86_64')
url="https://dev.maxmind.com/geoip/geoip2/downloadable/"
optdepends=('geoip2-database: IP geolocation databases')
source=("https://github.com/maxmind/libmaxminddb/releases/download/$pkgver/libmaxminddb-$pkgver.tar.gz")
sha256sums=('1107799f77be6aa3b9796ad0eed8ffcc334bf45f8bd18e6a984d8adf3e719c6d')

build() {
	cd "$srcdir"/libmaxminddb-$pkgver
	./configure --prefix=/usr
	make
}

check() {
	cd "$srcdir"/libmaxminddb-$pkgver
	make check
}

package_libmaxminddb() {
	pkgdesc="MaxMindDB GeoIP2 database library"
	depends=('glibc')

	cd "$srcdir"/libmaxminddb-$pkgver
	make PREFIX=/usr DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/{bin,share/man/man1}
}

package_mmdblookup() {
	pkgdesc="MaxMindDB GeoIP2 lookup utility"
	depends=('libmaxminddb')

	cd "$srcdir"/libmaxminddb-$pkgver
	make PREFIX=/usr DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/{lib,include,share/man/man3}
}
